<?
	$data['name'] = $_POST['name'];
	$data['type'] = $_POST['type'];
	$data['gid'] = $_POST['id'];
	$data['year'] = $_SESSION['year'];
	$data['sub'] = $_POST['sub'];

	$sql = "SELECT id FROM assessment WHERE year = ".$_SESSION['year']." and sub = ".$_POST['sub']." and gid = ".$_POST['id'];
	$have = $db->queryUniqueValue($sql);

	if(!$have){
		$id = $db->insert("assessment", $data);
	}else{
		alert("ตัวบงชี้ซ้ำ กรุณากรอกอีกครั้ง");
	}

	redirect("assessment.php?id=".$id);
?>